package com.forevershine.business.persistent.impl;

import org.apache.ibatis.session.SqlSession;

import com.forevershine.business.persistent.BaseDao;
import com.forevershine.business.persistent.IDataAccessor;

public class BaseDaoImpl<M> implements BaseDao<M> {

	@Override
	public void insert(IDataAccessor dataAccessor, M pojo, String sqlName) {
		SqlSession session =  dataAccessor.getSession();
		session.insert(sqlName, pojo);
		session.commit();
	}

	@Override
	public M load(IDataAccessor dataAccessor, int taskId, String sqlName) {
		SqlSession session =  dataAccessor.getSession();
		return (M)session.selectOne(sqlName, taskId);
	}

	@Override
	public void update(IDataAccessor dataAccessor, M pojo,
			String sqlName) {
		SqlSession session =  dataAccessor.getSession();
		session.update(sqlName, pojo);
		session.commit();		
	}

}
